

<div class="container-fluid">

            <div class="row-fluid">
                <div class="span12">
                    <h3 class="page-title">
                        活动管理 <small>活动列表</small>
                    </h3>
                    <ul class="breadcrumb">
                        <li>
                            <i class="icon-home"></i>
                            <a href="index.html">活动管理</a> 
                            <i class="icon-angle-right"></i>
                        </li>
                        <li><a href="#">活动列表</a></li>
                      
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
    
    
    
            

            <div class="row-fluid"> 

                <div class="portlet box blue">
                        <div class="portlet-title">
                                <div class="caption"><i class="icon-cogs"></i>活动列表</div>
                                
                                <div class="actions">
                                    <a href="" class="btn green" data-toggle="modal" data-target="#modalType" ><i calss="icon-pencil"></i>添加活动分类</a>
                                    <a href="<?php echo Yii::app()->createUrl(Yii::app()->params['adminUrl'].'/activity/add');?>" class="btn red"><i class="icon-pencil"></i>添加活动</a>
                                </div>  
                        </div>
                       <div class="portlet-body">
                          <?php
            $this->widget('bootstrap.widgets.TbGridView', array(
                'id' => 'table-Activity',
                'dataProvider' => $Activity->search(Yii::app()->user->Alumni_id),
                'filter' => $Activity,
              //  'enableHistory' =>'true',
                
                'htmlOptions' =>array('class'=>'table table-hover'),              
                'afterAjaxUpdate' => 'reinstallDatePicker',
                'summaryText' => '<font color="#0066A4"; style="float:right;">显示{start}-{end}条.共{count}条记录,当前第{page}页</font>', 
                'columns' => array(
                    array(
                        'name' => 'id',
                        'value' => '$data->id',
                        'headerHtmlOptions' =>array('style'=>'width:50px;'),
                       
                    ),
                    array(
                        'name' => 'title',
                      //  'value' => '$data->Dealname($data->title)',
                        'value' => '$data->title',
                        
                    ),
                    array(
                        'name' => 'type_id',
                        'header'=>'活动类型',
                        'value' => '$data->Type->name',
                        'filter' => $Activity->getTypeList($Activity->type_id),  
                    ),
                    
                    //array(
                      //  'name' => 'alumni_id',
                      //  'header'=>'总会名称',
                       // 'value' => '$data->Alumni->rename',
                    //),
                    
                    array(
                        'name' => 'cat_id',
                        'header'=>'活动分类',
                        'value' => '$data->getCat($data->cat_id)',
                        'filter' =>$Activity->getCatList($Activity->cat_id),  
                    ),
                    
                     array(
                        'name' => 'start_time',
                        'header'=>'活动开始时间',
                        'value' => 'date("Y-m-d",$data->start_time)',
                        'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                            'model' => $Activity,
                            'attribute' => 'start_time',
                            'language' => 'zh',              
                            'htmlOptions' => array(
                                'id' => 'datepicker_for_due_date',                       
                                'style' => 'height:20px;width:80px;',
                            ),
                            'options' => array(// 
                                'showAnim' =>'slideDown',
                                'dateFormat' => 'yy-mm-dd',
                                'showButtonPanel' => true,
                            )
                                ), true), //
                    ),
                    
                      array(
                        'name' => 'end_time',
                        'header'=>'活动结束时间',
                        'value' => 'date("Y-m-d",$data->end_time)',
                         'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                            'model' => $Activity,
                            'attribute' => 'end_time',
                            'language' => 'zh',              
                            'htmlOptions' => array(
                                'id' => 'datepicker_for_due_date1',                       
                                'style' => 'height:20px;width:80px;',
                            ),
                            'options' => array(// 
                                'showAnim' =>'slideDown',
                                'dateFormat' => 'yy-mm-dd',
                                 'firstDay'=>1,
                                'showButtonPanel' => true,
                            )
                                ), true), //
                    ),
                    array(
                        'name' => 'is_hot',
                        'header'=>'是否热点',
                        'value' => '$data->getHot($data->is_hot)',
                        'filter'=>FALSE
                       // 'htmlOptions' =>array('style'=>'width:10px;'),
                    ),
                    
                     array(
                        'name' => 'is_need_lottery',
                        'header'=>'抽奖设置',
                        'value' => '$data->getLottery($data->id)',
                        'filter'=>FALSE
                       // 'htmlOptions' =>array('style'=>'width:10px;'),
                    ),
                    
                    
                    array(
                   'header' => '操作',
                   'class' => 'bootstrap.widgets.TbButtonColumn',


                   'template' =>'{view}|{hot}|{edit}|{delete}',

                  'htmlOptions' =>array('style'=>'width:220px;'),
                   'buttons' => array(
                       'view' => array(
                           'label' => '查看',
                           'url' => 'Yii::app()->createUrl("xyhadm/activity/view",
                                   array(
                                           "id"=>$data->id,
                                        ))',
                          'options' => array(
//                                    'data-toggle' => 'modal',
//                                    'data-target' => '#view', 
                                    
                                    'class'=>'label label-info'
                           ),
                         ),

                        //'edit' =>'$data->is_edit($data->type_id)',
                       'edit'=>array(
                            'label' => '修改',
                             'url' => 'Yii::app()->createUrl("xyhadm/activity/edit",
                                   array(
                                           "id"=>$data->id,
                                        ))',
                           'options'=>array('class'=>'label label-success')

                       ),
                       'delete'=>array(
                           'label' =>'删除',
                           'options'=>array(
                                'class'=>'label label-danger'
                           )
                           
                       ),
                           'hot'=>array(
                           'label' =>'热点',
                           'url' =>'"javascript:hot(\"".$data->id."\",\"".$data->is_hot."\");"',
                           'options'=>array('class'=>'btn red mini')
                            

                       ),
//                        'lottery'=>array(
//                            'label' => '抽奖设置',
//                             'url' => 'Yii::app()->createUrl("xyhadm/activity/lottery",
//                                   array(
//                                           "id"=>$data->id,
//                                        ))',
//                           'options'=>array('class'=>'btn yellow mini',
//                              
//                               
//                               )
//
//                       ),
                       
//                        'hotCancel'=>array(
//                           'label' =>'取消热点',
//                           'url' =>   '"javascript:hot(\"".$data->id."\",\"".$data->is_hot."\");"',
//                           'options'=>array('class'=>'btn blue mini')
//                       )

                       ),        
                   ),
                    
                    
                    
                    
           
               
               ),
                
            ));
  Yii::app()->clientScript->registerScript('re-install-date-picker',"
            function reinstallDatePicker(id, data){ 
                $('#datepicker_for_due_date').datepicker(jQuery.extend(jQuery.datepicker.regional['en'],{'dateFormat':'yy-mm-dd'}));//
                $('#datepicker_for_due_date1').datepicker(jQuery.extend(jQuery.datepicker.regional['en'],{'dateFormat':'yy-mm-dd'}));//
               
}");
            
            
            
            
            ?> 
                </div> 
               </div>    
            </div>
</div>





<!-- 查看 -->

<div class="modal fade" style="width: 1050px; margin: -10px 0 0 -450px;" id="view"  tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
   <div class="modal-dialog">
        <div class="modal-content" id="prepaidData-content" style="width: 1050px; margin: -10px 0 0 -450px;">
        
            
        </div>      
    </div>  
</div>


<div class="modal fade" id="modalType"  tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
   <div class="modal-dialog">
        <div class="modal-content" id="prepaidData-content">
            
            
                 <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
                        <h3>添加活动分类</h3>
                </div>
            
            
            <div class="modal-body">
              
                <div class="control-group">
                    <label class="control-label">活动分类名称</label>
                    <div class="controls">
                        <input type="text" class="m-wrap small" name="Type[name]" id="Type_name">
                    </div>
                </div>

            </div>
             
            <div class="modal-footer">
            
            <?php
echo CHtml::ajaxSubmitButton('确定添加',Yii::app()->createUrl(Yii::app()->params['adminUrl'].'/activity/index'),
                    array(  
                        'type'=>'POST',                     
                        'data' => 'js:{"type_name":$("#Type_name").val()}',
                        'success'=>'js:function(data){ 
                            if(data){
                                
                                   $("#table-Activity").yiiGridView("update");
                                   $("#modalType").modal("hide");
                            } 
                            else{
                                    
                            }
                        }',   
                        'error'=>'js:function(){alert("对账失败!请重新选择日期");}'
                    ),array('class'=>'btn btn-info','id'=>'Submit_payment'));
                ?>
            </div>
            
        </div>      
    </div>  
</div>






<script type="text/javascript">


 function hot(id,is_hot){
        $.fn.yiiGridView.update('table-Activity',{
            type:'POST',
            url:$(this).attr('href'), 
             data:{'id':id,'is_hot':is_hot},
        });
    }



$('#view').on('hidden.bs.modal',function(e){
    $('div.modal-backdrop.fade.in').remove();
     history.go(0);
});



</script>